package hapiserverproject;

import java.io.IOException;

import ca.uhn.hl7v2.HL7Exception;
import ca.uhn.hl7v2.app.Application;
import ca.uhn.hl7v2.app.SimpleServer;
import ca.uhn.hl7v2.llp.LLPException;
import ca.uhn.hl7v2.llp.LowerLayerProtocol;
import ca.uhn.hl7v2.parser.EncodingNotSupportedException;
import ca.uhn.hl7v2.parser.PipeParser;

/**
 * Example code
 * 
 * @author <a href="mailto:james.agnew@uhn.on.ca">James Agnew</a>
 * @version $Revision: 1.1 $ updated on $Date: 2007/02/19 02:24:46 $ by $Author:
 *          jamesagnew $
 */
public class myHL7Server {

    /**
     * @param args
     * @throws HL7Exception
     * @throws EncodingNotSupportedException
     * @throws IOException
     * @throws LLPException
     */
    public static void main(String[] args)
            throws EncodingNotSupportedException, HL7Exception, LLPException,
            IOException {

        /*
         * Create a server to listen for incoming messages
         */

        int port = 2354; // The port to listen on
        LowerLayerProtocol llp = LowerLayerProtocol.makeLLP(); // The transport
                                                               // protocol
        PipeParser parser = new PipeParser(); // The message parser
        SimpleServer server = new SimpleServer(port, llp, parser);
        Application handler = new ExampleReceiverApplication();
        server.registerApplication("ADT", "A01", handler);
        server.registerApplication("ADT", "A05", handler);
        server.start();
    }

}
